package com.example.a2302fx.utils

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

/**
 * 图片加载框架，设置合适的缓存策略
 */
object GlideUtils {

    fun loadNormal(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .into(imageView)
    }
    fun loadCircle(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .circleCrop()
            .into(imageView)
    }
    fun loadCorner(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .transform(CenterCrop(),RoundedCorners(20))
            .into(imageView)
    }
}